R @ MMC

Costas T Lambrew Research Retreat

May 1, 2019

Visualize your data

plots

Create maps!

map

Statistics and machine learning

islr

Programmatically generate tables

tableone::CreateTableOne(
  vars =  c("time","status","age","sex","trig","stage"), 
  strata = "trt", data = survival::pbc, 
  factorVars =  c("status","trt","edema","stage"))
##                   Stratified by trt
##                    1                 2                 p      test
##   n                    158               154                      
##   time (mean (SD)) 2015.62 (1094.12) 1996.86 (1155.93)  0.883     
##   status (%)                                            0.894     
##      0                  83 (52.5)         85 (55.2)               
##      1                  10 ( 6.3)          9 ( 5.8)               
##      2                  65 (41.1)         60 (39.0)               
##   age (mean (SD))    51.42 (11.01)     48.58 (9.96)     0.018     
##   sex = f (%)          137 (86.7)        139 (90.3)     0.421     
##   trig (mean (SD))  124.14 (71.54)    125.25 (58.52)    0.886     
##   stage (%)                                             0.201     
##      1                  12 ( 7.6)          4 ( 2.6)               
##      2                  35 (22.2)         32 (20.8)               
##      3                  56 (35.4)         64 (41.6)               
##      4                  55 (34.8)         54 (35.1)

MMC R server

Access your work from any MaineHealth computer with a web browser

https://vmrstudiowebap

MMC R server

Install packages with ease

install.packages("tidyverse")

MMC R server

Use Python

import pandas as pd
my_series = pd.Series([2, 4, 6, 8, 10])
print(my_series.describe())
## count     5.000000
## mean      6.000000
## std       3.162278
## min       2.000000
## 25%       4.000000
## 50%       6.000000
## 75%       8.000000
## max      10.000000
## dtype: float64

MMC R server

Connect to databases

con <- dbConnect(odbc(), Driver = "{ODBC Driver 17 for SQL Server}", 
    Server = "localhost", 
    Database = "testdb", 
    UID = "SA", 
    PWD = rstudioapi::askForPassword("Database password"), 
    Port = 1433)

MMC R user group

  • Get help from peers
  • Meets first Tuesday of every month at CORE
  • Upcoming topics
  • Programmatic tables
  • Baysian multilevel modeling
  • Causal inference and Structural Equation Modeling
  • Big data

Data Carpentry Workshop at Core